<template>
    <el-container>
        <!-- 赛选查询框 -->
        <el-header>
            <el-row :gutter="20">
            <el-col :span="4">
                <el-input v-model="goodsParam.goodsEnteringPerson" placeholder="请输入操作人" ></el-input>
            </el-col>
            <el-col :span="20">
                <el-row >
                    <el-col :span="7">
                        <el-input v-show="selectInput.inputShow" v-model="goodsInput" :placeholder="inputText"></el-input>
                        <span v-show="selectInput.stetusShow">
                            <template>
                            <el-radio v-model="goodsParam.goodsStatus" label="待评估">待评估</el-radio>
                            <el-radio v-model="goodsParam.goodsStatus" label="已评估">已评估</el-radio>
                            </template>
                        </span>
                    </el-col>
                    <el-col :span="3">
                        <el-select v-model="goodsInputTerm"  placeholder="请选择活查询内容">
                            <el-option label="商品名" value="goodsName"></el-option>
                            <el-option label="分类" value="sortName"></el-option>
                            <el-option label="鉴定人" value="goodsDefinePerson"></el-option>
                            <el-option label="状态" value="goodsStatus"></el-option>
                        </el-select>
                    </el-col>
                    <el-col :span="3">
                        <el-button @click="selectGoodsInput" round>查询</el-button>
                    </el-col>
                </el-row>
            </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="6">
                    <el-date-picker v-model="goodsParam.startTime" type="date" placeholder="开始日期"></el-date-picker>
                </el-col>
                <el-col :span="6">
                    <el-date-picker v-model="goodsParam.endTime" type="date" placeholder="结束日期"></el-date-picker>
                </el-col>
                <el-col :span="6">
                    <el-button @click="addGoodsPageShow=true" type="primary">新增商品</el-button>
                </el-col>
            </el-row>
        </el-header>
        <el-main>
            <el-table ref="ids" tooltip-effect="dark" :data="goods" border style="width: 100%"  @selection-change="handleSelectionChange">
            <el-table-column type="selection"  width="55" >
                </el-table-column>
            <el-table-column  prop="goodsId"  label="编号"  width="50">
            </el-table-column>
                <el-table-column  prop="goodsName"  label="商品名称"  width="120">
                </el-table-column>
                    <el-table-column  prop="sortName"  label="分类"  width="100">
                    </el-table-column>
                <el-table-column  prop="goodsEnteringPerson"  label="录入人" width="80">
                </el-table-column>
                <el-table-column  prop="goodsDefinePerson"  label="鉴定人" width="80">
                </el-table-column>
                <el-table-column  prop="goodsAssessPerson"  label="评估人" width="80">
                </el-table-column>
                <el-table-column  prop="goodsEnteringTime"  label="录入时间" width="140">
                </el-table-column>
                <el-table-column  prop="goodsStatus"  label="状态" width="80">
                </el-table-column>
                <el-table-column fixed="right" label="操作" width="140">
                    <template slot-scope="scope">
                        <el-button @click="goodsMessageInfo(scope.row)" type="text" size="small">查看</el-button>
                        <el-button type="text" size="small">编辑</el-button>
                        <el-button type="text" size="small" @click="accessDataClick(scope.row)">估价</el-button>
                        <el-button type="text" size="small" @click="identifyDataClick(scope.row)">鉴定</el-button>
                        <el-button type="text" size="small" @click="deleteGoodss(scope.row)">删除</el-button>

                    </template>
                </el-table-column>
            </el-table>
            <el-pagination background layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChange" @current-change="pageChange" :page-sizes="[3, 5, 10, 20]" :page-size="pageData.pageSize" :total="pageData.total">
            </el-pagination>

            <!-- 添加新商品页面 -->
            <el-dialog title="添加新商品" :visible.sync="addGoodsPageShow">
                <el-container>
                    <el-aside width="200px">
                        <el-button type="success">商品信息</el-button>
                        <el-button type="success">商品属性</el-button>
                        <el-button type="success">商品图片</el-button>
                        <el-button type="success">确定信息</el-button>
                    </el-aside>
                    <el-main>
                        <el-row :gutter="20">
                            <!-- 信息页面 -->
                            <el-col :span="20" v-show="selectInput.addMessageShow">
                                <el-form ref="form" :model="goodsParam" label-width="80px">
                                    <el-form-item label="商品名称">
                                        <el-input v-model="goodsParam.goodsName"></el-input>
                                    </el-form-item>
                                    <el-form-item label="商品分类">
                                        <el-select v-model="goodsParam.sortoj" placeholder="请选择">
                                            <el-option v-for="item in sorts" :key="item.sortName" :label="item.sortName" :value="item">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="商品品牌">
                                        <el-select v-model="goodsParam.brandoj" placeholder="请选择">
                                            <el-option v-for="item in brands" :key="item.brandId" :label="item.brandName" :value="item">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="来源门店">
                                    <el-select v-model="goodsParam.storeoj" placeholder="请选择">
                                            <el-option v-for="item in stores" :key="item.storeId" :label="item.storeName" :value="item">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="商品货号">
                                        <el-input v-model="goodsParam.goodsNum"></el-input>
                                    </el-form-item>
                                    <el-form-item label="商品首买价">
                                        <el-input v-model="goodsParam.goodsFirstBuy"></el-input>
                                    </el-form-item>
                                    <el-form-item label="商品描述">
                                        <el-input v-model="goodsParam.goodsDepict"></el-input>
                                    </el-form-item>
                                    <el-form-item>
                                        <el-button type="primary" @click="onSubmit(1)">下一步</el-button>
                                        <el-button @click="onSubmit(0)">取消</el-button>
                                    </el-form-item>
                                </el-form>
                            </el-col>
                            <!-- 属性页面 -->
                            <el-col :span="20" v-show="selectInput.addPorpertyShow">
                                <el-form ref="form" :model="goodsParam" label-width="80px">
                                    <el-form-item label="材质">
                                        <el-select v-model="goodsParam.material"  placeholder="请选择活查询内容">
                                            <el-option label="皮革" value="皮革"></el-option>
                                            <el-option label="布料" value="布料"></el-option>
                                            <el-option label="合金" value="合金"></el-option>
                                            <el-option label="陶瓷" value="陶瓷"></el-option>
                                            <el-option label="木料" value="木料"></el-option>
                                            <el-option label="橡胶" value="橡胶"></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="颜色">
                                        <el-select v-model="goodsParam.colour"  placeholder="请选择活查询内容">
                                            <el-option label="红色" value="红色"></el-option>
                                            <el-option label="黄色" value="黄色"></el-option>
                                            <el-option label="蓝色" value="蓝色"></el-option>
                                            <el-option label="绿色" value="绿色"></el-option>
                                            <el-option label="青色" value="青色"></el-option>
                                            <el-option label="紫色" value="紫色"></el-option>
                                            <el-option label="橙色" value="橙色"></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="上市时间">
                                        <el-date-picker v-model="goodsParam.goodsMarketTime" type="date" placeholder="上市时间"></el-date-picker>
                                    </el-form-item>
                                    <el-form-item label="适用对象">
                                        <div>
                                            <el-checkbox-group v-model="goodsParam.goodsApplyObject">
                                                <el-checkbox label="少女"></el-checkbox>
                                                <el-checkbox label="职业女性"></el-checkbox>
                                                <el-checkbox label="少年"></el-checkbox>
                                                <el-checkbox label="大叔"></el-checkbox>
                                            </el-checkbox-group>
                                        </div>
                                    </el-form-item>
                                    <el-form-item label="配件">
                                        <el-input v-model="goodsParam.goodsParts"></el-input>
                                    </el-form-item>
                                    <el-form-item>
                                        <el-button type="primary" @click="onSubmit(1)">上一步</el-button>
                                        <el-button @click="onSubmit(2)">下一步</el-button>
                                        <el-button @click="onSubmit(0)">取消</el-button>
                                    </el-form-item>
                                </el-form>
                            </el-col>
                            <!-- 图片页面 -->
                            <el-col :span="20" v-show="selectInput.addImgyShow">
                                <el-form ref="form" :model="goodsParam" label-width="80px">
                                    <el-upload class="upload-demo" action="http://localhost:80/file/upload" name="file" :on-success="filesucess" list-type="picture">
                                        <el-button size="small" type="primary">点击上传</el-button>
					                </el-upload>
                                    <el-form-item>
                                        <el-button type="primary" @click="onSubmit(2)">上一步</el-button>
                                        <el-button @click="onSubmit(3)">下一步</el-button>
                                        <el-button @click="onSubmit(0)">取消</el-button>
                                    </el-form-item>
                                </el-form>
                            </el-col>
                            <!-- 完成页面 -->
                            <el-col :span="20" v-show="selectInput.addAllyShow">
                                <el-descriptions class="margin-top" title="查看填写信息" :column="3" size="size" border>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品名称
                                    </template>
                                    {{goodsParam.goodsName}}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品分类
                                    </template>
                                    {{goodsParam.sortName}}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品品牌
                                    </template>
                                    {{goodsParam.brandName}}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        来源门店
                                    </template>
                                    {{goodsParam.storeName}}
                                    </el-descriptions-item>
                                    
                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品货号
                                    </template>
                                    {{goodsParam.goodsNum}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        首买价价格
                                    </template>
                                    {{goodsParam.goodsFirstBuy}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品描述
                                    </template>
                                    {{goodsParam.goodsDepict}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        材质
                                    </template>
                                    {{goodsParam.material}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        颜色
                                    </template>
                                    {{goodsParam.colour}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        上市时间
                                    </template>
                                    {{goodsParam.goodsMarketTime}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        适用对象
                                    </template>
                                    {{goodsParam.goodsApplyObject}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        配件
                                    </template>
                                    {{goodsParam.goodsParts}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品图片
                                    </template>
                                    <span v-for="(url,key) in goodsParam.goodsImgs" :key="key">
                                        <el-image style="width: 100px; height: 100px" :src="url" fit="contain"></el-image>
                                    </span>
                                    </el-descriptions-item>
                                    <template slot="extra">
                                    <el-button type="primary" size="small" @click="onSubmit(4)">确定</el-button>
                                    <el-button type="primary" size="small" @click="onSubmit(0)">取消</el-button>
                                    </template>
                                </el-descriptions>
                            </el-col>

                        </el-row>
                    </el-main>
                </el-container>

            </el-dialog>
            <!-- 查看商品 -->
            <el-dialog title="查看商品信息" :visible.sync="goodsInfoPageShow">
                <el-container>
                    <el-aside width="200px">
                        <el-button type="success" @click="onSubmit(5)">商品信息</el-button>
                        <el-button type="success" @click="onSubmit(6)">估价历史</el-button>
                        <el-button type="success" @click="onSubmit(7)">鉴定历史</el-button>
                    </el-aside>
                    <el-main>
                        <el-row :gutter="20">
                            <el-col :span="20" v-show="selectInput.showMessage">
                            <el-descriptions class="margin-top" title="查看填写信息" :column="3" size="size" border>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品名称
                                    </template>
                                    {{goodsParam.goodsName}}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品分类
                                    </template>
                                    {{goodsParam.sortName}}
                                    </el-descriptions-item>
                                    <!-- <el-descriptions-item>
                                    <template slot="label">
                                        商品品牌
                                    </template>
                                    {{brandIdToName(goodsParam.goodsId)}}
                                    </el-descriptions-item> -->
                                    <el-descriptions-item>
                                    <template slot="label">
                                        来源门店
                                    </template>
                                    {{goodsParam.storeName}}
                                    </el-descriptions-item>
                                    
                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品货号
                                    </template>
                                    {{goodsParam.goodsNum}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        首买价价格
                                    </template>
                                    {{goodsParam.goodsFirstBuy}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品描述
                                    </template>
                                    {{goodsParam.goodsDepict}}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        录入人
                                    </template>
                                    {{goodsParam.goodsEnteringPerson}}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        鉴定人
                                    </template>
                                    {{goodsParam.goodsDefinePerson}}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        评估人
                                    </template>
                                    {{goodsParam.goodsAssessPerson}}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        录入时间
                                    </template>
                                    {{goodsParam.goodsEnteringTime}}
                                    </el-descriptions-item>
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                    <template slot="label">
                                        状态
                                    </template>
                                    {{goodsParam.goodsStatus}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        上市时间
                                    </template>
                                    {{goodsParam.goodsMarketTime}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        适用对象
                                    </template>
                                    {{goodsParam.goodsApplyObject}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        配件
                                    </template>
                                    {{goodsParam.goodsParts}}
                                    </el-descriptions-item>

                                    <el-descriptions-item>
                                    <template slot="label">
                                        商品图片
                                    </template>
                                    <span v-for="(url,key) in goodsImg" :key="key">
                                        <el-image style="width: 100px; height: 100px" :src="url.gimgUrl" fit="contain"></el-image>
                                    </span>
                                    </el-descriptions-item>
                                    <template slot="extra">
                                    <el-button type="primary" size="small" @click="onSubmit(8)">关闭</el-button>
                                    </template>
                                </el-descriptions>
                            </el-col>
                            <el-col :span="20" v-show="selectInput.showgIdentify">
                                <el-table ref="ids" tooltip-effect="dark" :data="identifyData" border style="width: 100%"  @selection-change="handleSelectionChange">
                                    <el-table-column type="selection"  width="55" >
                                        </el-table-column>
                                    <el-table-column  prop="goodsId"  label="编号"  width="50">
                                    </el-table-column>
                                        <el-table-column  prop="goodsName"  label="商品名称"  width="120">
                                            <template slot-scope="scope">
                                            <span :key="scope.row.identifyId">{{goodsParam.goodsName}}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column  prop="identifyType"  label="鉴定类型" width="80">
                                        </el-table-column>
                                        <el-table-column  prop="identifyDegree"  label="新旧程度" width="80">
                                        </el-table-column>
                                        <el-table-column  prop="goodsDefinePerson"  label="鉴定人" width="80">
                                        </el-table-column>
                                        <el-table-column  prop="goodsDefineTime"  label="鉴定时间" width="140">
                                        </el-table-column>
                                        <el-table-column  prop="identifyRemark"  label="鉴定备注" width="80">
                                        </el-table-column>
                                    </el-table>
                            </el-col>
                            <el-col :span="20" v-show="selectInput.showAssess">
                                <el-table ref="ids" tooltip-effect="dark" :data="accessData" border style="width: 100%"  @selection-change="handleSelectionChange">
                                    <el-table-column type="selection"  width="55" >
                                        </el-table-column>
                                    <el-table-column  prop="goodsId"  label="编号"  width="50">
                                    </el-table-column>
                                        <el-table-column  prop="goodsName"  label="商品名称"  width="120">
                                            <template slot-scope="scope">
                                            <span :key="scope.row.assessId">{{goodsParam.goodsName}}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column  prop="assessMoney1"  label="官方价" width="80">
                                        </el-table-column>
                                        <el-table-column  prop="assessMoney2"  label="评估价" width="80">
                                        </el-table-column>
                                        <el-table-column  prop="goodsAssessPerson"  label="评估人" width="80">
                                        </el-table-column>
                                        <el-table-column  prop="goodsAssessTime"  label="评估时间" width="140">
                                        </el-table-column>
                                        <el-table-column  prop="assessRemark"  label="评估备注" width="80">
                                        </el-table-column>
                                    </el-table>
                            </el-col>
                        </el-row>
                    </el-main>
                </el-container>
            </el-dialog>
            <!-- 鉴定页面 -->
            <el-dialog title="鉴定页面" :visible.sync="identifyDataPageShow">
                <el-form ref="form" :model="identifyData" label-width="80px">
                    <el-form-item label="商品名称">
                        <el-input v-model="identifyData.goodsName" :placeholder="identifyData.goodsName"></el-input>
                    </el-form-item>
                    <el-form-item label="新旧程度">
                        <el-input v-model="identifyData.identifyDegree"></el-input>
                    </el-form-item>
                    <el-form-item label="鉴定类型">
                        <el-select v-model="identifyData.identifyType" placeholder="请选择鉴定类型">
                        <el-option label="真品" value="真品"></el-option>
                        <el-option label="假货" value="假货"></el-option>
                        <el-option label="资料不全" value="资料不全"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="鉴定备注">
                        <el-input v-model="identifyData.identifyRemark"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="addidentifyData">上传鉴定</el-button>
                        <el-button>取消</el-button>
                    </el-form-item>
                    </el-form>
            </el-dialog>
            <!-- 估价页面 -->
            <el-dialog title="估价页面" :visible.sync="accessDataPageShow">
                <el-form ref="form" :model="accessData" label-width="80px">
                    <el-form-item label="商品名称">
                        <el-input v-model="accessData.goodsName" :placeholder="accessData.goodsName"></el-input>
                    </el-form-item>
                    <el-form-item label="官方价">
                        <el-input v-model="accessData.assessMoney1" :placeholder="accessData.assessMoney1"></el-input>
                    </el-form-item>
                    <el-form-item label="评估价">
                        <el-input v-model="accessData.assessMoney2"></el-input>
                    </el-form-item>
                    <el-form-item label="评估备注">
                        <el-input v-model="accessData.assessRemark"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="addaccessData">上传评估</el-button>
                        <el-button>取消</el-button>
                    </el-form-item>
                    </el-form>
            </el-dialog>
        </el-main>
    </el-container>
</template>
<script>
export default {
    name:"GoodsShow",
    data(){
        return{
            goodsInput:"",
            goodsInputTerm:"goodsName",
            goods:[],
           // 存储分页数据
            pageData: {
                total: 10,
                pageSize: 10,
                pageIndex: 1
            },
            goodsParam:{
                goodsId:null,
                goodsStatus:null,//状态
                goodsName:null,//商品名称
                sortoj:null,//sort对象
                sortName:null,//分类名称
                sortId:null,//分类Id
                brandoj:null,//brand对象
                brandName:null,//关联商品品牌名称
                brandId:null,//关联商品品牌id
                goodsNum:null,//商品货号
                goodsFirstBuy:null,//首买价格
                goodsDepict:null,//商品描述
                material:null,//商品材质
                colour:null,//商品颜色
                goodsApplyObject:[],//商品适用对象
                goodsMarketTime:null,//商品上市时间
                goodsParts:null,//商品配件
                storeoj:null,//store对象
                storeId:null,//门店id
                storeName:null,//门店名称
                goodsEnteringPerson:null,//录入人
                goodsDefinePerson:null,//鉴定人
                goodsAssessPerson:null,//评估人
                startTime:null,//开始时间
                endTime:null,//结束时间
                goodsImgs:[],//图片集合
            },//提交goods
            addGoodsPageShow:false,//添加商品页面开关
            goodsInfoPageShow:false,//单个商品详情页面
            identifyDataPageShow:false,//添加鉴定页面开关
            accessDataPageShow:false,//添加估价页面开关
            selectInput:{
                inputShow:true,
                stetusShow:false,
                addMessageShow:true,
                addPorpertyShow:false,
                addImgyShow:false,
                addAllyShow:false,
                //查看模块
                showMessage:true,
                showgIdentify:false,
                showAssess:false,

            },
            sorts:[],//分类集合
            brands:[],//品牌集合
            stores:[],//门店集合
            propertys:[],//属性集合
            identifyData:{
                goodsName:null,
                identifyId:null,
                identifyType:null,//鉴定类型（真品，假货，资料不全）
                identifyDegree:null,//新旧程度
                goodsDefinePerson:null,//鉴定人
                goodsDefineTime:null,//鉴定时间
                identifyRemark:null,//鉴定备注
                goodsId:null,//商品表id
            },
            accessData:{
                goodsName:null,
                assessId:null,
                assessMoney1:null,//官方价
                assessMoney2:null,//评估价
                goodsAssessPerson:null,//评估人
                goodsAssessTime:null,//评估时间
                assessRemark:null,//评估备注
                goodsId:null,//商品表id
            },
            goodsImg:{},
        }
    },
    methods:{
        //查询分页列表
        query(){
            if(null != this.goodsParam.startTime){
                this.goodsParam.startTime =  this.goodsParam.startTime.getTime();
            }
            if(null != this.goodsParam.endTime){
                this.goodsParam.endTime = this.goodsParam.endTime.getTime();
            }
            this.addObjectToValue();
            let getGoods={
                    pageDto:this.pageData,
                    goodsParam:this.goodsParam,
            };
            console.log(getGoods);
            this.$http.post('/goods/queryAllGoods',getGoods)
            .then(res=>{
                console.log(res)
                if (res.data.state) {
                    //3. 查询，返回分页相关数据，赋值给pageData
                    Object.assign(this.pageData, res.data.data)
                    this.goods = res.data.data.records
                    for(let i=0;i<res.data.data.records.length;i++){
                        let time = res.data.data.records[i].goodsEnteringTime
                        let date = new Date(time)
                        this.goods[i].goodsEnteringTime = [date.getFullYear(),date.getMonth()+1,date.getDate()].join('-')+' '+[date.getHours(),date.getSeconds(),date.getMinutes()].join(':')
                    }
                }
                this.emptyInputMethod();
            }).catch(err=>{
                console.log(err)
            })
		},
        //输入框查询功能
        selectGoodsInput(){
            console.log(this.goodsParam.startTime);
            console.log(this.goodsParam.endTime);
            switch(this.goodsInputTerm){
                case 'goodsName':
                    this.goodsParam.goodsName=this.goodsInput;
                    break;
                case 'goodsDefinePerson':
                    this.goodsParam.sortName=this.goodsInput;
                    break;
            }
            this.query();
            this.emptyInputMethod();
        },
        //添加商品
        addGoods(){
            if(null != this.goodsParam.goodsMarketTime){
                this.goodsParam.goodsMarketTime =  this.goodsParam.goodsMarketTime.getTime();
            }
            let getGoods={
                    pageDto:this.pageData,
                    goodsParam:this.goodsParam,
            };
            console.log(getGoods);
            this.$http.post('/goods/addGoods',getGoods)
            .then(res=>{
                console.log(res)
                let data = res.data;
                if (data.state) {
                    let good = data.data;
                    good.goodsEnteringTime = [date.getFullYear(),date.getMonth()+1,date.getDate()].join('-')+' '+[date.getHours(),date.getSeconds(),date.getMinutes()].join(':');
                    this.goods.splice(0,0,good);
                    this.emptyInputMethod();
                }
            }).catch(err=>{
                console.log(err)
            })
        },
        //删除商品
        deleteGoodss(row){
            let id = row.goodsId;
            console.log(row);
            
            this.$http.get("/goods/delateGoods",{
                params:{
                    ids:id,
                }
             })
            .then(resp=>{
                console.log("删除商品");
                console.log(resp);
                let data = resp.data;
                if(data.state){
                    for(let i=0;i<this.goods.length;i++){
                        if(this.goods[i].goodsId ==id ){
                            this.goods.splice(i,1);
                            break;
                        }
                    }
                }
                alert(data.massage)
            })
            .catch(err=>{
                console.log(err)
            })
        },
        //添加鉴定功能
        addidentifyData(){
            let getIdentify = {
                pageDto:this.pageDto,
                identifyParam:this.identifyData,
            }
            this.$http.post("/identify/identifyTure",getIdentify)
            .then(resp=>{
                console.log("添加鉴定功能");
                console.log(resp);
                let data = resp.data;
                if(data.state){
                    for(let i=0;i<this.goods.length;i++){
                        if(this.goods[i].goodsId ==this.identifyData.goodsId ){
                            let good = this.goods[i];
                            good.goodsStatus='已鉴定';
                            alert(data.massage)
                            this.identifyDataPageShow = false;
                            break;
                        }
                    }
                }
                
            })
            .catch(err=>{
                console.log(err)
            })
        },
        //添加估价功能
        addaccessData(){
            let getAssess = {
                pageDto:this.pageDto,
                assessParam:this.accessData,
            }
            console.log(getAssess);
            this.$http.post("/assess/addAssess",getAssess)
            .then(resp=>{
                console.log("添加估价功能");
                console.log(resp);
                let data = resp.data;
                if(data.state){
                    for(let i=0;i<this.goods.length;i++){
                        if(this.goods[i].goodsId ==this.accessData.goodsId ){
                            let good = this.goods[i];
                            good.goodsStatus='已评估';
                            break;
                        }
                    }
                }
                alert(data.massage);
                this.accessDataPageShow = false;
            })
            .catch(err=>{
                console.log(err)
            })
        },
        //查看商品详情页面
        goodsMessageInfo(row){

            this.goodsInfoPageShow = true;
            console.log(row);
            this.goodsParam = row;
            //获取估价历史
            this.getAssess();
            //获取鉴定历史
            this.getIdentify();
             //获取数据库商品图片
            this.getGoodsImg();

        },
        //打开添加鉴定商品页面
        identifyDataClick(row){
            this.identifyDataPageShow = true;
            console.log(row);
            this.identifyData.goodsId = row.goodsId;
            this.identifyData.goodsName = row.goodsName;
        },
        //打开估价鉴定商品页面
        accessDataClick(row){
            if(row.goodsStatus != '已鉴定'){
                alert("该商品未鉴定");
                return;
            }
            this.accessDataPageShow = true;
            console.log(row);
            this.accessData.goodsId = row.goodsId;
            this.accessData.goodsName = row.goodsName;
            this.accessData.assessMoney1=row.goodsPrice1;
        },
        //获取估价历史
        getAssess(){
            this.$http.get("/assess/queryAllAssess",{
                params:{
                    goodsId:this.goodsParam.goodsId,
                    pageSize:this.pageData.pageSize,
                    current:this.pageIndex,
                }
            }).then(resp=>{
                console.log("估价");
                console.log(resp)
                this.accessData=resp.data.data.records
            })
		},
        //获取鉴定历史
        getIdentify(){
            this.$http.get("/identify/queryAllIdentify",{
                params:{
                    goodsId:this.goodsParam.goodsId,
                    pageSize:this.pageData.pageSize,
                    current:this.pageIndex,
                }
            }).then(resp=>{
                console.log("鉴定");
                console.log(resp)
                this.identifyData=resp.data.data.records;
            })
		},
        //获取数据库商品图片
        getGoodsImg(){
            this.$http.get("/goodsImg/getGoodsImg",{
                params:{
                    goodsId:this.goodsParam.goodsId,
                    pageSize:this.pageData.pageSize,
                    current:this.pageIndex,
                }
            }).then(resp=>{
                console.log("图片");
                console.log(resp);
                this.goodsImg=resp.data.data.records;
                console.log(this.goodsImg)
            })
		},
        //获取上传图片地址
        filesucess(response,file){
				this.goodsParam.goodsImgs.push(response.data);
		},
        //记录勾选Id
        handleSelectionChange(val){
            console.log(val)
            this.ids=[]
            for(let i=0;i<val.length;i++){
                this.ids.push(val[i].goodsId)
            }
            console.log(this.ids)
		},
        //分页区
        pageSizeChange(ps) {
            this.pageData.pageSize = ps;
            this.query();
        },
        pageChange(p) {
            this.pageData.pageIndex = p;
            this.query();
        },
        //添加页面流程
        onSubmit(i){
            this.selectInput.addMessageShow=false;
            this.selectInput.addPorpertyShow=false;
            this.selectInput.addImgyShow=false;
            this.selectInput.addAllyShow=false;
            //查看商品
            this.selectInput.showMessage=false;
            this.selectInput.showgIdentify=false;
            this.selectInput.showAssess=false;
            switch(i){
                case 0:
                    this.selectInput.addMessageShow=true;
                    this.emptyInputMethod();
                    break;
                case 1:
                    this.selectInput.addPorpertyShow=true;
                    break;
                case 2:
                    this.selectInput.addImgyShow=true;
                    break;
                case 3:
                    this.addObjectToValue();
                    this.selectInput.addAllyShow=true;
                    break;
                case 4:
                    this.addGoods();
                    this.selectInput.addMessageShow=true;
                    this.addGoodsPageShow=false;
                    this.emptyInputMethod();
                    break;
                case 5:
                    this.selectInput.showMessage=true;
                    break;
                case 6:
                    this.selectInput.showgIdentify=true;
                    break;
                case 7:
                    this.selectInput.showAssess=true;
                    break;
                case 8:
                    this.selectInput.showMessage=true;
                    this.goodsInfoPageShow = false;
                    this.emptyInputMethod();
                    break;
            }
        },
        //添加对象转对应属性
        addObjectToValue(){
            let gp = this.goodsParam;
            if(null != gp.sortoj){
                gp.sortName = gp.sortoj.sortName;
                gp.sortId = gp.sortoj.sortId;
            }
            if(null != gp.storeoj){
                gp.storeName = gp.storeoj.storeName;
                gp.storeId = gp.storeoj.storeId;
            }
            if(null != gp.brandoj){
                gp.brandName = gp.brandoj.brandName;
                gp.brandId = gp.brandoj.brandId;
            }
            gp.goodsApplyObject = gp.goodsApplyObject+"";
            console.log("kakk");
            console.log(this.goodsParam);
        },

        //获取分类集合
        getSrots(){
            this.$http.get("pawnbackgroundsystem/sort/getGoodsSmall")
            .then(resp=>{
                console.log(resp);
                let data = resp.data;
                if(data.state){
                    let data1 = data.data;
                    this.sorts = data1;
                }
            })
            .catch(error=>{
                console.log(error);
            })
        },
        //获取品牌集合
        getBrands(){
            this.$http.get("pawnbackgroundsystem/brand/getGoodsBrand")
            .then(resp=>{
                console.log(resp);
                let data = resp.data;
                if(data.state){
                    let data1 = data.data;
                    this.brands = data1;
                }
            })
            .catch(error=>{
                console.log(error);
            })
        },
        //获取门店集合
        getStores(){
            this.$http.get("pawnbackgroundsystem/store/getStore")
            .then(resp=>{
                console.log(resp);
                let data = resp.data;
                if(data.state){
                    let data1 = data.data;
                    this.stores = data1;
                }
            })
            .catch(error=>{
                console.log(error);
            })
        },
        //获取属性集合
        getPropertys(){
            this.$http.get("pawnbackgroundsystem/property/getPropertyName")
            .then(resp=>{
                console.log(resp);
                let data = resp.data;
                if(data.state){
                    let data1 = data.data;
                    this.propertys = data1;
                }
            })
            .catch(error=>{
                console.log(error);
            })
        },

        //清空条件
        emptyInputMethod(){
            let  goodsParam={
                goodsId:null,
                goodsStatus:null,//状态
                goodsName:null,//商品名称
                sortName:null,//分类名称
                sortId:null,//分类Id
                brandName:null,//关联商品品牌名称
                brandId:null,//关联商品品牌id
                goodsNum:null,//商品货号
                goodsFirstBuy:null,//首买价格
                goodsDepict:null,//商品描述
                material:null,//商品材质
                colour:null,//商品颜色
                goodsApplyObject:[],//商品适用对象
                goodsMarketTime:null,//商品上市时间
                goodsParts:null,//商品配件
                sortId:null,//分类Id
                storeId:null,//门店id
                storeName:null,//门店名称
                goodsEnteringPerson:null,//录入人
                goodsDefinePerson:null,//鉴定人
                goodsAssessPerson:null,//评估人
                startTime:null,//开始时间
                endTime:null,//结束时间
                goodsImgs:[],//图片集合
            };//提交goods
            this.goodsParam = goodsParam;
        }
    },
    computed:{
        inputText(){
            this.goodsInput='';
            this.selectInput.inputShow=true;
            this.selectInput.stetusShow=false;
            switch(this.goodsInputTerm){
                case 'goodsName':
                    return '请输入商品名称';
                case 'sortName':
                    return '请输入分类';
                case 'goodsStatus':
                    this.selectInput.inputShow=false;
                    this.selectInput.stetusShow=true;
                    return '请选择状态';
                case 'goodsDefinePerson':
                    return '请输入鉴定人';
            }
        }
    },
    mounted(){
		this.query();//商品信息
        //获取分类集合
        this.getSrots();
        //获取品牌集合
        this.getBrands();
        //获取门店集合
        this.getStores();
        //获取属性集合
        this.getPropertys();
	},
}
</script>